<?php
class Zendvn_View_Helper_CmsAdminLanguage extends Zend_View_Helper_Abstract{
	
	
	public function cmsAdminLanguage($arrParam = null,$options = null ){
		
		$language 	= new Zendvn_Languages();
		
		$data 		= $language->getDataLanguage('admin');
		$interface 	= $language->getInterfaceLanguage('admin');
		
		$linkChange	= str_replace('/', '.', $this->view->url());
		$optionArr	= array('module'=>'default','controller'=>'admin','action'=>'change-lang');
		$link 	= $this->view->url($optionArr);
		
		
		$slbLanguage = $language->listLanguage();
		/*===========================================================
		 * Change image selectbox
		 *===========================================================*/
		if($interface == 'en'){
			$styleInterface = 'background: url(' . PUBLIC_URL .'/img/flags/en.png) #fff left center no-repeat; width: 120px; padding-left: 24px;';
		}else if($interface == 'vi'){
			$styleInterface = 'background: url(' . PUBLIC_URL .'/img/flags/vi.png) #fff left center no-repeat; width: 120px; padding-left: 24px;';
		}
		
		if($data == 'en'){
			$styleData = 'background: url(' . PUBLIC_URL .'/img/flags/en.png) #fff left center no-repeat; width: 120px; padding-left: 24px;';
		}else if($data == 'vi'){
			$styleData = 'background: url(' . PUBLIC_URL .'/img/flags/vi.png) #fff left center no-repeat; width: 120px; padding-left: 24px;';
		}
		
		if(count($slbLanguage)>1){
			
			$interfaceAttribs = array('onchange'=>"changeLang('" . $link . "','interface',this.value,'" . $linkChange . "');",'style'=>$styleInterface);
			$databaseAttribs = array('onchange'=>"changeLang('" . $link . "','database',this.value,'" . $linkChange . "');",'style'=>$styleData);
			
			$xhtml = '<div style="float: right; margin-right: 15px; margin-top: 2px;">' 
					 . $this->view->translate('Interface language') . ': '
					 . $this->view->formSelect('data-lang',$interface,$interfaceAttribs,$slbLanguage) . ' '
					 . $this->view->translate('Database language') . ': '
					 . $this->view->formSelect('interface-lang',$data,$databaseAttribs,$slbLanguage)
					 . ' </div>'
	     			 . '<div class="clr"></div>';
		}
		return $xhtml;
	}
	
	protected function change(){
		
	}
}